1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module soup.MessageHeadersIter;
26 
27 private import glib.MemorySlice;
28 private import glib.Str;
29 private import glib.c.functions;
30 private import gobject.ObjectG;
31 private import soup.MessageHeaders;
32 private import soup.c.functions;
33 public  import soup.c.types;
34 
35 
36 /**
37  * An opaque type used to iterate over a %SoupMessageHeaders
38  * structure.
39  * 
40  * After intializing the iterator with
41  * soup_message_headers_iter_init(), call
42  * soup_message_headers_iter_next() to fetch data from it.
43  * 
44  * You may not modify the headers while iterating over them.
45  */
46 public class MessageHeadersIter
47 {
48 	/** the main Gtk struct */
49 	protected SoupMessageHeadersIter* soupMessageHeadersIter;
50 	protected bool ownedRef;
51 
52 	/** Get the main Gtk struct */
53 	public SoupMessageHeadersIter* getMessageHeadersIterStruct(bool transferOwnership = false)
54 	{
55 		if (transferOwnership)
56 			ownedRef = false;
57 		return soupMessageHeadersIter;
58 	}
59 
60 	/** the main Gtk struct as a void* */
61 	protected void* getStruct()
62 	{
63 		return cast(void*)soupMessageHeadersIter;
64 	}
65 
66 	/**
67 	 * Sets our main struct and passes it to the parent class.
68 	 */
69 	public this (SoupMessageHeadersIter* soupMessageHeadersIter, bool ownedRef = false)
70 	{
71 		this.soupMessageHeadersIter = soupMessageHeadersIter;
72 		this.ownedRef = ownedRef;
73 	}
74 
75 
76 	/**
77 	 * Yields the next name/value pair in the %SoupMessageHeaders being
78 	 * iterated by @iter. If @iter has already yielded the last header,
79 	 * then soup_message_headers_iter_next() will return %FALSE and @name
80 	 * and @value will be unchanged.
81 	 *
82 	 * Params:
83 	 *     name = pointer to a variable to return
84 	 *         the header name in
85 	 *     value = pointer to a variable to return
86 	 *         the header value in
87 	 *
88 	 * Returns: %TRUE if another name and value were returned, %FALSE
89 	 *     if the end of the headers has been reached.
90 	 */
91 	public bool next(out string name, out string value)
92 	{
93 		char* outname = null;
94 		char* outvalue = null;
95 
96 		auto __p = soup_message_headers_iter_next(soupMessageHeadersIter, &outname, &outvalue) != 0;
97 
98 		name = Str.toString(outname);
99 		value = Str.toString(outvalue);
100 
101 		return __p;
102 	}
103 
104 	/**
105 	 * Initializes @iter for iterating @hdrs.
106 	 *
107 	 * Params:
108 	 *     iter = a pointer to a %SoupMessageHeadersIter
109 	 *         structure
110 	 *     hdrs = a %SoupMessageHeaders
111 	 */
112 	public static void init(out MessageHeadersIter iter, MessageHeaders hdrs)
113 	{
114 		SoupMessageHeadersIter* outiter = sliceNew!SoupMessageHeadersIter();
115 
116 		soup_message_headers_iter_init(outiter, (hdrs is null) ? null : hdrs.getMessageHeadersStruct());
117 
118 		iter = ObjectG.getDObject!(MessageHeadersIter)(outiter, true);
119 	}
120 }